package br.com.democracia.services;

import java.util.List;

import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceContext;
import javax.servlet.RequestDispatcher;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.democracia.entity.Login;
import br.com.democracia.entity.Usuario;

@Service
@Transactional
public class UsuarioService {

	@PersistenceContext
	private EntityManager entityManager;

	public void add(Usuario usuario, Login login) {
		System.out.println("gravar");
		try {
			entityManager.persist(usuario);
			entityManager.persist(login);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void login(Login login){
		System.out.println("logando");
		System.out.println(login.getNomeusuario()+"usuario " +login.getSenha()+ "senha");
		FacesContext fc = FacesContext.getCurrentInstance();
		try {
			if(login.getNomeusuario().equals("clemilson") && login.getSenha().equals("admin1234")){
				
			}else{
				System.out.println("jdjfdsk");
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
